<?php

/*

Forum View Topic (global_view_topic.php)

*/

$interactive = 1;
$page_title = "Global Forums - View Topic";
$rank_check = 3;
include "header.inc.php";

$message = fetch("SELECT * FROM global_topics WHERE id = '$id'");
$subject = fetch("SELECT * FROM global_subjects WHERE id = '$id'");
$get_author = fetch("SELECT id,username,display_name,global_post_count,premium,display_prem,ip_addr,game FROM members2 WHERE id = '$subject[author]'");
$get_author2 = fetch("SELECT signature,gender FROM members_profiles2 WHERE username = '$get_author[username]' AND game = '$get_author[game]'");
if (($get_author[premium] == 1) AND ($get_author[display_prem]))
{
	$get_author[display_name] = $get_author[display_prem];
}

if (($get_author[premium] == 1) AND ($message[colors]))
{
	if ($message[colors])
	{
		$explodeColors = explode(", ", $message[colors]);
		if ($explodeColors[0])
		{
			$textColor = "<font color=\"$explodeColors[0]\">";
			$textColorEnd = "</font>";
		}
		if ($explodeColors[1])
		{
			$cellColor = "$explodeColors[1]";
		}
	}
}

if ($get_author2[signature])
{
	$get_author2[signature] = smilies($get_author2[signature]);
	$author_sig = "<hr width=75% color=\"$tableOutline\"><p>$get_author2[signature]</p>";
}

$gender = $get_author2[gender] ;
$genderArray = array("<img src=images/icons/undecided.gif>", "<img src=images/icons/female.gif>", "<img src=images/icons/male.gif>");
$authorLine = $genderArray[$gender];

$datestring = date("g:i:s, M j",$message[timestamp]);

print "
<SCRIPT LANGUAGE=\"JavaScript\">
function insertSmiley(code)
{
	document.reply.add_reply.value += code;
}
</script>
";

print "<p><b>Welcome to the forums. Failure to obey the rules may result in suspension of your account. <font color=red>Remember to Keep it clean, anything over G will be deleted.</font></b></p>";

if (($rank >= 4) AND ($subject[reports] >= 5))
{
	$delete_thread = "<a href='global_forum_delete.pro.php?game=$game&topic=$subject[id]]' onClick=\"if ( !confirm ('Are you sure you want to delete this post?') ) { return false; }\">Delete Topic</a> ";
}

if ($quote)
{
	$findQuote = fetch("SELECT message,author FROM global_replies WHERE thread = '$id' AND id = '$quote'");
	$findQuoter = fetch("SELECT display_name,premium,display_prem,game FROM members2 WHERE id = '$findQuote[author]'");
	if (($findQuoter[premium] == 1) AND ($findQuoter[display_prem]))
	{
		$findQuoter[display_name] = $findQuoter[display_prem];
	}

	$findQuote[message] = stripslashes(unquote(unsmilies(unformat($findQuote[message]))));

	$add_reply = "(quote)Quote by $findQuoter[display_name] .. Game #$findQuoter[game] - $findQuote[message](endquote)\n\n";
}

ECHO <<<END

<center>
<form action=global_add_topic.php?game=$game method=post>
<input type=submit value="Add Topic">
</form>
<br>
<a href=#add_reply>Add a reply to this topic!</a></center>

END;

if ($rank == "7") { $ifAdminIP = "<p align=center><font size=-1>$get_author[ip_addr]</font></p>"; }

if (!$cellColor) { $cellColor = "#FFFFFF"; }

print "<table width=95% BGCOLOR=\"$middleBG\" CELLSPACING=1 CELLPADDING=0 width=95%>
<tr bgcolor=$topAndBottomBG><td colspan=2><p><font color=$topAndBottomText>$subject[subject]</font></td></tr>

<tr width=100%><td width=125 valign=top bgcolor=#FFFFFF><font size=-1><a href=$base_url/global_profile.php?game=$game&user=$get_author[id]>$get_author[display_name] - Game #$get_author[game]</a><br>
$datestring<br>Posts: $get_author[global_post_count]<br>$delete_thread</p><p>$authorLine</p>$ifAdminIP</td><td valign=top bgcolor=$cellColor>$textColor$message[message]$author_sig$textColorEnd</a></td></tr>";

$numReplies2 = fetch("SELECT count(id) AS id FROM global_replies WHERE thread = '$id'");

if ($numReplies2[id] == 0) { $numReplies2[id] = 1; }
$num_pages = ceil($numReplies2[id] / 25);
if (!$page) { $page = 1; }
$start = 25 * ($page-1);
$replies = mysql_query("SELECT * FROM global_replies WHERE thread = '$id' ORDER BY posted_at LIMIT $start,25");

$x = 1;
$list_pages = "<p><font color=$topAndBottomText>Pages: </font>";

while ($x <= $num_pages)
{
	if ($x == $num_pages)
	{
		$end[$x] = "</p>";
	}
	if ($x < $num_pages)
	{
		$end[$x] = ", ";
	}
	$list_pages .= "<a href=$base_url/global_view_topic.php?game=$game&id=$id&page=$x>$x</a>$end[$x]";
	$x++;
}

echo "<tr bgcolor=$topAndBottomBG><td colspan=2>$list_pages</td></tr>";

while ($array = mysql_fetch_array($replies))
{
	if (($rank >= 4) AND ($array[reports] >= "5")) { $delete_reply = " (<a href='global_forum_delete.pro.php?game=$game&reply=$array[id]&goto=$id' onClick=\"if ( !confirm ('Are you sure you want to delete this post?') ) { return false; }\">Delete</a>)<br>"; }
	$get_responder = fetch("SELECT id,username,display_name,global_post_count,premium,display_prem,ip_addr,game FROM members2 WHERE id = '$array[author]'");
	$get_responder2 = fetch("SELECT signature,gender,mail_settings FROM members_profiles2 WHERE username = '$get_responder[username]' AND game = '$get_responder[game]'");
	if (($get_responder[premium] == 1) AND ($get_responder[display_prem]))
	{
		$get_responder[display_name] = $get_responder[display_prem];
	}
	$textColor = "";
	$textColorEnd = "";
	$cellColor = "";

	if (($get_responder[premium] == 1) AND ($array[colors]))
	{
		if ($array[colors])
		{
			$explodeColors = explode(", ", $array[colors]);
			if ($explodeColors[0])
			{
				$textColor = "<font color=\"$explodeColors[0]\">";
				$textColorEnd = "</font>";
			}
			if ($explodeColors[1])
			{
				$cellColor = "$explodeColors[1]";
			}
		}
	}
	if ($get_responder2[signature])
	{
		$get_responder2[signature] = smilies($get_responder2[signature]);
		$responder_sig = "<hr width=75% color=\"$tableOutline\"><p>$get_responder2[signature]</p>";
	}
	else
	{
		$responder_sig = "";
	}

	$gender = $get_responder2[gender];
	$genderArray = array("<img src=images/icons/undecided.gif>", "<img src=images/icons/female.gif>", "<img src=images/icons/male.gif>");
	$authorLine = $genderArray[$gender];

	if (!$cellColor) { $cellColor = "#FFFFFF"; }

	if ($rank == "7") { $ifAdminIP = "<p align=center><font size=-1>$get_responder[ip_addr]</font></p>"; }

	$posted_at = date("g:i:s, M j",$array[posted_at]);
	echo "<tr bgcolor=#FFFFFF width=100%><td bcolor=#FFFFFF width=125 valign=top><font size=-1>Post By: <a href=$base_url/global_profile.php?game=$game&user=$get_responder[id]>$get_responder[display_name] - Game #$get_responder[game]</a> @<br><font size=-1>$posted_at</font><br>Posts: $get_responder[post_count] <br>$delete_reply<a href=global_view_topic.php?game=$game&page=$page&id=$id&quote=$array[id]#add_reply><img src=images/icons/quote.gif height=14 width=14></a>$authorLine</p>$ifAdminIP</td><td valign=top bgcolor=\"$cellColor\">$textColor$array[message]$responder_sig$textColorEnd</a></b></i></u></td></tr>";
}

echo "</table><br><CENTER><p>$list_pages";

print "<FORM NAME=reply ACTION=$base_url/global_add_reply.pro.php?game=$game&reply_to=$id&page=$page METHOD=POST>";

if ($getInfo[premium] == "1")
{

ECHO <<<PREM

<CENTER><TABLE BGCOLOR="#99CCFF" CELLSPACING=0 CELLPADDING=0 WIDTH=300>
   <TR>
      <TD HEIGHT=25>
         <P><B>Text Color:&nbsp;&nbsp;&nbsp;</B></P>
      </TD>
      <TD HEIGHT=25>
         <P><SELECT NAME=text_color>
            <OPTION value="#000000">Black
        	<OPTION value="#FFFFFF">White
            <OPTION value="#990000">Dark Red
			<OPTION value="#FF0000">Red
			<OPTION value="#FF9999">Light Red
			<OPTION value="#FF3300">Orange Red
			<OPTION value="#FFCC99">Light Orange
			<OPTION value="#FFCC00">Orange
			<OPTION value="#FFFF33">Yellow
			<OPTION value="#006600">Green
			<OPTION value="#00FF00">Light Green
			<OPTION value="#009999">Green Blue
			<OPTION value="#00FFFF">Light Blue
			<OPTION value="#0066FF">Blue
			<OPTION value="#0000FF">Dark Blue
			<OPTION value="#9900CC">Purple
			<OPTION value="#CCCCFF">Light Purple
			<OPTION value="#FF0099">Pink
			<OPTION value="#FF99FF">Light Pink
         </SELECT></P>
      </TD>
   </TR>
   <TR BGCOLOR="#66CCFF">
      <TD HEIGHT=25>
         <P><B>Background Color:&nbsp;&nbsp;&nbsp;</B></P>
      </TD>
      <TD HEIGHT=25>
         <P><SELECT NAME=bg_color>
            <OPTION value="#FFFFFF">White
        	<OPTION value="#000000">Black
            <OPTION value="#990000">Dark Red
			<OPTION value="#FF0000">Red
			<OPTION value="#FF9999">Light Red
			<OPTION value="#FF3300">Orange Red
			<OPTION value="#FFCC99">Light Orange
			<OPTION value="#FFCC00">Orange
			<OPTION value="#FFFF33">Yellow
			<OPTION value="#006600">Green
			<OPTION value="#00FF00">Light Green
			<OPTION value="#009999">Green Blue
			<OPTION value="#00FFFF">Light Blue
			<OPTION value="#0066FF">Blue
			<OPTION value="#0000FF">Dark Blue
			<OPTION value="#9900CC">Purple
			<OPTION value="#CCCCFF">Light Purple
			<OPTION value="#FF0099">Pink
			<OPTION value="#FF99FF">Light Pink
         </SELECT></P>
      </TD>
   </TR>
   <TR>
      <TD HEIGHT=25>
         <P><B>Background Image:&nbsp;&nbsp;&nbsp;</B></P>
      </TD>
      <TD HEIGHT=25>
         <P><SELECT NAME=bg_image>
            <OPTION>None
            <OPTION value=hearts>Hearts
            <OPTION value=clover>Clover
            <OPTION value=rainbow>Rainbow
            <OPTION value=cookie>Cookie
            <OPTION value=ghost>Ghost
            <OPTION value=flower>Flowers
            <OPTION value=dollar>Dollar Sign
            <OPTION value=cross>Cross
            <OPTION value=duct_tape>Duct Tape
         </SELECT></P>
      </TD>
   </TR>
</TABLE>
</CENTER>

PREM;

}

ECHO <<<POSTRE

<CENTER><TABLE BGCOLOR="$middleBG" CELLSPACING=1 CELLPADDING=0 WIDTH=450>
   <TR BGCOLOR="$topAndBottomBG">
      <TD WIDTH="100%" HEIGHT=16>
         <P><B><A NAME="add_reply"></A><font color=$topAndBottomText>Add Reply:</font></B></P>
      </TD>
   </TR>
   <TR BGCOLOR="#FFFFFF">
      <TD WIDTH="100%">
         <CENTER><TABLE CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
            <TR>
               <TD WIDTH=100>
                  <CENTER><TABLE BGCOLOR="#E3E3E3" CELLSPACING=0 CELLPADDING=0 WIDTH=80 HEIGHT=90>
                     <TR>
                        <TD>
                           <CENTER>
                           	<a href='javascript:;' onClick='insertSmiley(" >:O ");
	return false;'><IMG SRC="images/smilies/spid3r/angry.gif" WIDTH=16 HEIGHT=16></a>
                           <a href='javascript:;' onClick='insertSmiley(" :-d ");
	return false;'><IMG SRC="images/smilies/spid3r/bigsmile.gif" WIDTH=16 HEIGHT=16></a>
                           <a href='javascript:;' onClick='insertSmiley(" :*( ");
	return false;'><IMG SRC="images/smilies/spid3r/crying.gif" WIDTH=16 HEIGHT=16></a><BR>
                           <a href='javascript:;' onClick='insertSmiley(" 0_o ");
	return false;'><IMG SRC="images/smilies/spid3r/oosmilie.gif" WIDTH=16 HEIGHT=16></a>
                           <a href='javascript:;' onClick='insertSmiley(" :-p ");
	return false;'><IMG SRC="images/smilies/spid3r/psmile.gif" WIDTH=16 HEIGHT=16></a>
                           <a href='javascript:;' onClick='insertSmiley(" :( ");
	return false;'><IMG SRC="images/smilies/spid3r/sad.gif" WIDTH=16 HEIGHT=16></a><BR>
                           <a href='javascript:;' onClick='insertSmiley(" :) ");
	return false;'><IMG SRC="images/smilies/spid3r/smilie.gif" WIDTH=16 HEIGHT=16></a>
                           <a href='javascript:;' onClick='insertSmiley(" ;) ");
	return false;'><IMG SRC="images/smilies/spid3r/wink.gif" WIDTH=16 HEIGHT=16></a>
							<a href='javascript:;' onClick='insertSmiley(" 8-) ");
	return false;'><IMG SRC="images/smilies/flowers65/cool.gif" WIDTH=16 HEIGHT=16></a>
                           </CENTER>
                        </TD>
                     </TR>
                  </TABLE>
                  </CENTER>
               </TD>
               <TD>
                  <CENTER><BR>
                  <TEXTAREA NAME="add_reply" ROWS=10 COLS=40 WRAP=virtual>$add_reply</TEXTAREA><BR>
                  <BR>
                  </CENTER>
               </TD>
            </TR>
         </TABLE>
         </CENTER>
      </TD>
   </TR>
   <TR BGCOLOR="$reallyLight">
      <TD WIDTH="100%" HEIGHT=30>
         <CENTER><INPUT TYPE=submit NAME=Submit VALUE="Post Message"></CENTER>
      </TD>
   </TR>
</TABLE>
<FONT SIZE="-1"><I>(You must be at least 13 to use the Global
Forums!)</I></FONT></CENTER>
</form>

POSTRE;

?>